<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:a4j="http://richfaces.org/a4j"
                xmlns:rich="http://richfaces.org/rich">
    <h:head>
        <style type="text/css">
            input[type='submit']{
                margin: 3px 5px 3px 5px;
                padding: 3px 5px 3px 5px;
            }
            .itemClass{
                width:20px;
            }
        </style>
        <script type="text/javascript">
            function testQuery(butId){
                var ok = confirm('申请后无法撤销，是否继续！');
                if(ok){
                   var _button = document.getElementById(butId);
                    _button.disabled = 'true';
                }
                return ok;
            }
        </script>
    </h:head>
    <h:form id="asset">
        <rich:panel header="报废/报损申请" styleClass="content-hight">
            <a4j:commandButton value="查询"
                               action="#{psnAsset.initAskForli}"
                               render="@this,dataGroup"/>
            <a4j:commandButton id="askScrapped" value="申请报废"
                               action="#{psnAsset.askForScrapped}"
                               onclick="return testQuery('asset:askScrapped');"
                               render="@this,dataGroup"/>
            <a4j:commandButton id="askLost" value="申请报损"
                               action="#{psnAsset.askForLost}"
                               onclick="return testQuery('asset:askLost');"
                               render="@this,dataGroup"/>
            <a4j:commandButton value="撤销申请"
                               action="#{psnAsset.askForCancel}"
                               onclick="this.disabled = 'true';"
                               rendered="false"
                               render="@this,dataGroup"/>
            <hr/>
            <h:panelGroup id="dataGroup">
                <rich:dataScroller for="assetList" fastStep="3" render="dataGroup"/>
                <div style="width:750px;min-height: 200px;overflow: auto;">
                    <rich:dataTable style="width:1200px;margin-bottom: 5px;"
                                    id="assetList"
                                    value="#{psnAsset.askForli}"
                                    rows="10"
                                    var="asset"
                                    styleClass="stable"
                                    noDataLabel="无数据！">
                        <rich:column style="text-align:center;width:40px;">
                            <f:facet name="header">
                                <h:outputText  value="选择"/>
                            </f:facet>
                            <h:selectBooleanCheckbox value="#{asset.selected}"
                                                     disabled="#{asset.useStatus eq 1 or asset.useStatus eq 2}">
                                <a4j:ajax event="click" execute="@this"/>
                            </h:selectBooleanCheckbox>
                        </rich:column>
                        <rich:column style="text-align: center;width:55px;">
                            <f:facet name="header">
                                <h:outputText  value="使用状况"/>
                            </f:facet>
                            <h:outputText value="在用" rendered="#{asset.useStatus eq 0}"/>
                            <h:outputText value="报废" rendered="#{asset.useStatus eq 1 and asset.checkFlag}" style="color: blue"/>
                            <h:outputText value="报损" rendered="#{asset.useStatus eq 2 and asset.checkFlag}" style="color: red"/>
                            <h:outputText value="其他" rendered="#{asset.useStatus eq 3}" style="color: orange"/>
                            <h:outputText value="申请报废" rendered="#{asset.useStatus eq 1 and !asset.checkFlag}" style="color: #3baae3"/>
                            <h:outputText value="申请报损" rendered="#{asset.useStatus eq 2 and !asset.checkFlag}" style="color: indianred"/>
                        </rich:column>
                        <rich:column>
                            <f:facet name="header">
                                <h:outputText  value="资产编号"/>
                            </f:facet>
                            <h:outputText value="#{asset.assetCode}"/>
                        </rich:column>
                        <rich:column>
                            <f:facet name="header">
                                <h:outputText  value="资产名称"/>
                            </f:facet>
                            <h:outputText value="#{asset.assetName}"/>
                        </rich:column>
                        <rich:column>
                            <f:facet name="header">
                                <h:outputText  value="品牌"/>
                            </f:facet>
                            <h:outputText value="#{asset.brand}"/>
                        </rich:column>
                        <rich:column>
                            <f:facet name="header">
                                <h:outputText  value="规格型号"/>
                            </f:facet>
                            <h:outputText value="#{asset.model}"/>
                        </rich:column>
                        <rich:column>
                            <f:facet name="header">
                                <h:outputText  value="单价"/>
                            </f:facet>
                            <h:outputText value="#{asset.price}"/>
                        </rich:column>
                        <rich:column>
                            <f:facet name="header">
                                <h:outputText  value="购置日期"/>
                            </f:facet>
                            <h:outputText value="#{asset.purchDate}">
                                <f:convertDateTime pattern="yyyy年MM月dd日" timeZone="GMT+8" locale="cn" />
                            </h:outputText>
                        </rich:column>
                        <rich:column style="width:160px;">
                            <f:facet name="header">
                                <h:outputText  value="保管地点"/>
                            </f:facet>
                            <h:outputText value="#{asset.place}"/>
                        </rich:column>
                        <rich:column>
                            <f:facet name="header">
                                <h:outputText  value="厂商"/>
                            </f:facet>
                            <h:outputText value="#{asset.manufacture}"/>
                        </rich:column>
                        <rich:column>
                            <f:facet name="header">
                                <h:outputText  value="质保日期"/>
                            </f:facet>
                            <h:outputText value="#{asset.shelfLife}">
                                <f:convertDateTime pattern="yyyy年MM月dd日" timeZone="GMT+8" locale="cn" />
                            </h:outputText>
                        </rich:column>
                        <rich:column>
                            <f:facet name="header">
                                <h:outputText  value="保管人"/>
                            </f:facet>
                            <h:outputText value="#{asset.keeper.cpsn_name}"/>
                        </rich:column>
                        <rich:column>
                            <f:facet name="header">
                                <h:outputText  value="使用人"/>
                            </f:facet>
                            <h:outputText value="#{asset.person.cpsn_name}"/>
                        </rich:column>
                        <rich:column style="width:160px;">
                            <f:facet name="header">
                                <h:outputText  value="备注"/>
                            </f:facet>
                            <h:outputText value="#{asset.memo}"/>
                        </rich:column>
                    </rich:dataTable>
            <rich:jQuery selector=".stable tr:odd" query="addClass('odd-row')" />
            <rich:jQuery selector=".stable tr:even" query="addClass('even-row')" />
            <rich:jQuery selector=".stable tr" event="mouseover" query="jQuery(this).addClass('active-row')" />
            <rich:jQuery selector=".stable tr" event="mouseout" query="jQuery(this).removeClass('active-row')" />
            <rich:jQuery selector=".stable tr" event="click" query="jQuery(this).addClass('click-row')"/>
            <rich:jQuery selector=".stable tr" event="click" query="jQuery('.stable tr').not(this).removeClass('click-row')"/>
                </div>
            </h:panelGroup>
        </rich:panel>
    </h:form>
</ui:composition>
